<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>国内折扣</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <script src="../utils/flexible.js"></script>
    <link rel="stylesheet" href="../css/inlanddiscount.css">
</head>
<body>
    <header>
        <button>返回</button>
        <p> 国内折扣</p>
        <img src="../images/header_app.png" alt="">
    </header>
    <!-- 商品折扣列表 -->
    <ul class="ulall">

    </ul>


    <!-- 底部 -->
    <footer>
        <ul>
            <li>登录</li>
            <li>注册</li>
            <li class="returntop">返回顶部</li>
        </ul>
        <p>
            手机APP下载慢慢买手机版-掌上比价平台<br>
            m.manmanbuy.com
        </p>
    </footer>
</body> 
</html>

<script>
    // 返回上一级
    let bn=document.querySelector('button');
    bn.addEventListener('click',function(){
        history.go(-1);
    })

    // 商品折扣列表函数
    function render1(data=[]){
        let html='';
        data.forEach(item=>{
            html+=`
                <li productid=${item.productId}>
                    ${item.productImg} 
                    ${item.productName}<br>
                    ${item.productPrice}<br>  
                    ${item.productFrom} <br>
                    ${item.productTime}
                    
                </li>
            `
        })
        $('.ulall').html(html);
    }





    // 获取商品折扣列表数据
    $.ajax({
        url:'http://chst.vip:1234/api/getinlanddiscount'
    })
    .then(res=>{
        console.log(res);
        render1(res.result);
        $('.ulall').on('click','li',function(){
            let productid=$(this).attr('productid')
            location.href=`./inlandproduct.html?productid=${productid}`
        })
    })


       // 返回顶部
       $('footer .returntop').click(function(e){
            document.documentElement.scrollTop=0;
        })
    
</script>